const UNIT_MAP = {
	m: 1,
	minute: 1,
	h: 60,
	hour: 60,
	d: 60 * 24,
	day: 60 * 24,
	w: 60 * 24 * 7,
	week: 60 * 24 * 7,
	month: 60 * 24 * 30,
	y: 60 * 24 * 30 * 12,
	year: 60 * 24 * 30 * 12,
};

export default function timeUnitConver(limitObj, unit) {
	const limitMinutes = limitObj.value * UNIT_MAP[limitObj.unit];
	return Math.floor(1 / (UNIT_MAP[unit] / limitMinutes));
}

export function turnToMinute(obj) {
	if (!obj) return 0;
	const minutes = obj.num * UNIT_MAP[obj.unit];
	return minutes;
}
